package com.springboot.redis.controller;

import com.springboot.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Desc:
 * @Date: 2020-07-12
 * @Version:v1.0
 */
@RestController
public class RedisController {

    @Autowired
    private RedisService redisService;

    @RequestMapping("/set")
    @ResponseBody
    public String set(@RequestParam("key") String key, @RequestParam("value") String value) {
        redisService.set(key, value);
        System.out.println("redis 设置成功");
        return "{\"code\":200, \"msg\":\"success\"}";
    }

    @RequestMapping("/get")
    @ResponseBody
    public String get(@RequestParam("key") String key) {
        System.out.println("redis 获取值成功");
        return redisService.get(key);
    }


}
